--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Commit 29071fbdfcc8da5d77d8c7d558ae095646103459
Parents : 96d671e
Author : Mark Qvist <mark@unsigned.io>
Date : 2022-10-02T14:03:56+02:00
Dark/light mode theme support
Changes
3 files changed, 37 insertions(+), 5 deletions(-)
Diff
diff --git a/sbapp/main.py b/sbapp/main.py
index 9dd58a0b..5fd2c780 100644
--- a/sbapp/main.py
+++ b/sbapp/main.py
@@ -70,7 +70,6 @@ class SidebandApp(MDApp):
self.title = "Sideband"
self.app_state = SidebandApp.STARTING
self.android_service = None
-
self.app_dir = plyer.storagepath.get_application_dir()
if RNS.vendor.platformutils.get_platform() == "android":
@@ -78,8 +77,9 @@ class SidebandApp(MDApp):
else:
self.sideband = SidebandCore(self, is_client=False)
- self.conversations_view = None
+ self.update_ui_theme()
+ self.conversations_view = None
self.sync_dialog = None
Window.softinput_mode = "below_target"
@@ -138,6 +138,12 @@ class SidebandApp(MDApp):
# General helpers #
#################################################
+ def update_ui_theme(self):
+ if self.sideband.config["dark_ui"]:
+ self.theme_cls.theme_style = "Dark"
+ else:
+ self.theme_cls.theme_style = "Light"
+
def share_text(self, text):
if RNS.vendor.platformutils.get_platform() == "android":
Intent = autoclass('android.content.Intent')
@@ -198,7 +204,6 @@ class SidebandApp(MDApp):
def build(self):
FONT_PATH = self.sideband.asset_dir+"/fonts"
- self.theme_cls.theme_style = "Dark"
screen = Builder.load_string(root_layout)
return screen
@@ -708,6 +713,12 @@ class SidebandApp(MDApp):
self.sideband.config["lxmf_propagation_node"] = new_addr
self.sideband.set_active_propagation_node(self.sideband.config["lxmf_propagation_node"])
+ def save_dark_ui(sender=None, event=None):
+ RNS.log("Save UI mode")
+ self.sideband.config["dark_ui"] = self.root.ids.settings_dark_ui.active
+ self.sideband.save_configuration()
+ self.update_ui_theme()
+
def save_start_announce(sender=None, event=None):
RNS.log("Save announce")
self.sideband.config["start_announce"] = self.root.ids.settings_start_announce.active
@@ -738,6 +749,9 @@ class SidebandApp(MDApp):
self.root.ids.settings_propagation_node_address.bind(on_text_validate=save_prop_addr)
self.root.ids.settings_propagation_node_address.bind(focus=save_prop_addr)
+ self.root.ids.settings_dark_ui.active = self.sideband.config["dark_ui"]
+ self.root.ids.settings_dark_ui.bind(active=save_dark_ui)
+
self.root.ids.settings_start_announce.active = self.sideband.config["start_announce"]
self.root.ids.settings_start_announce.bind(active=save_start_announce)
@@ -1040,8 +1054,6 @@ If you use Reticulum and LXMF on hardware that does not carry any identifiers ti
Thank you very much for using Free Communications Systems.
"""
- guide_text = "[color=#ddd]"+guide_text+"[/color]"
-
info = guide_text
self.root.ids.guide_info.text = info
self.root.ids.guide_info.bind(on_ref_press=link_exec)
diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py
index f1185365..c2fbbca9 100644
--- a/sbapp/sideband/core.py
+++ b/sbapp/sideband/core.py
@@ -155,6 +155,7 @@ class SidebandCore():
self.config = {}
# Settings
self.config["display_name"] = "Anonymous Peer"
+ self.config["dark_ui"] = True
self.config["start_announce"] = False
self.config["propagation_by_default"] = False
self.config["home_node_as_broadcast_repeater"] = False
@@ -199,6 +200,11 @@ class SidebandCore():
self.config = msgpack.unpackb(config_file.read())
config_file.close()
+ # Migration actions from earlier config formats
+ if not "dark_ui" in self.config:
+ self.config["dark_ui"] = True
+
+ # Make sure we have a database
if not os.path.isfile(self.db_path):
self.__db_init()
else:
diff --git a/sbapp/ui/layouts.py b/sbapp/ui/layouts.py
index e12f1b39..dc1b76c4 100644
--- a/sbapp/ui/layouts.py
+++ b/sbapp/ui/layouts.py
@@ -670,6 +670,20 @@ MDNavigationLayout:
id: settings_start_announce
active: False
+ MDBoxLayout:
+ orientation: "horizontal"
+ # spacing: "24dp"
+ size_hint_y: None
+ height: dp(48)
+
+ MDLabel:
+ text: "Dark Mode UI"
+ font_style: "H6"
+
+ MDSwitch:
+ id: settings_dark_ui
+ active: False
+
MDBoxLayout:
orientation: "horizontal"
# spacing: "24dp"
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────